<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div></div>
  <script>
    var box = document.querySelector("div");

    // 在js里面去连接后端接口
    // fetch是h5新增的请求方式
    fetch("https://sapi.k780.com/?app=weather.realtime&weaId=1&ag=today,futureDay,lifeIndex,futureHour&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json").then(function(response) {
      // response就是后端返回的内容
      return response.json();
    }).then(function (res) {
      console.log(res);
      box.innerHTML = res.result.area_1 + "当前是" + res.result.realTime
.wtTemp + "度"
    })
  </script>
</body>
</html>